<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />

        <title>{% block title %}Packagist{% endblock %}</title>
        <meta name="description" content="{% block description %}The PHP Package Repository{% endblock %}" />
        <meta name="author" content="Jordi Boggiano" />
        {% block head_canonical %}<meta name="canonical" href="{{ app.request.uri }}" />{% endblock %}

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />

        <link rel="stylesheet" href="{{ asset('libs/bootstrap-3.3.5/css/bootstrap.min.css') }}" />
        <link rel="stylesheet" href="{{ asset('libs/bootstrap-3.3.5/css/bootstrap-theme.min.css') }}" />
        <link rel="stylesheet" href="{{ asset('bundles/packagistweb/css/main.css') }}" />
        <link rel="stylesheet" href="{{ asset('css/humane/jackedup.css') }}" />
        {% block stylesheets %}{% endblock %}

        {% block head_feeds %}
        <link rel="alternate" type="application/rss+xml" title="Newly Submitted Packages - Packagist" href="{{ url('feed_packages', {_format: 'rss'}) }}" />
        <link rel="alternate" type="application/rss+xml" title="New Releases - Packagist" href="{{ url('feed_releases', {_format: 'rss'}) }}" />
        {% endblock %}

        <link rel="search" type="application/opensearchdescription+xml" href="{{ asset('search.osd') }}" title="Packagist" />

        {% if not app.user and requires_recaptcha(lastUsername|default) %}
            <script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=onloadRecaptchaCallback" async defer></script>

            <script type="text/javascript">
                var onloadRecaptchaCallback = function() {
                    if (document.getElementById('_submit')) {
                        grecaptcha.render('_submit', {
                            'sitekey' : '{{ recaptcha_site_key }}',
                            'callback' : onPageLoginSubmit
                        });
                    }
                    grecaptcha.render('_submit_mini', {
                        'sitekey' : '{{ recaptcha_site_key }}',
                        'callback' : onNavLoginSubmit
                    });
                };
                function onNavLoginSubmit(token) {
                    document.getElementById('nav_login').submit();
                }
                function onPageLoginSubmit(token) {
                    document.getElementById('page_login').submit();
                }
            </script>
        {% endif %}

        {% block head_additions %}{% endblock %}
    </head>

    <body>
    <section class="wrap">
        <header class="navbar-wrapper navbar-fixed-top">
            <nav class="container">
                <div class="navbar" role="navigation">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                            <span class="sr-only">{{ 'menu.togglenav'|trans }}</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <h1 class="navbar-brand"><a href="{{ path('home') }}">{{ 'brandname'|trans }}</a> <em class="hidden-sm hidden-xs">{{ 'navclaim'|trans }}</em></h1>
                    </div>

                    <div class="collapse navbar-collapse">
                        <ul class="nav navbar-nav">
                            <li>
                                <a href="{{ path('browse') }}">{{ 'menu.browse'|trans }}</a>
                            </li>
                            <li>
                                <a href="{{ path('submit') }}">{{ 'menu.submit'|trans }}</a>
                            </li>
                        {%- if app.user %}
                            <li class="nav-user">
                                <section>
                                    <a href="{{ path('fos_user_profile_show') }}">{{ app.user.username }}</a>

                                    <section class="nav-user-menu">
                                        {{ knp_menu_render('user_menu', {'allow_safe_labels': true}) }}
                                    </section>
                                </section>
                            </li>
                            <li class="nav-user visible-xs-block">
                                <section>
                                    <a href="{{ path('logout') }}">Logout</a>
                                </section>
                            </li>
                        {%- else %}
                            <li>
                                <a href="{{ path('fos_user_registration_register') }}">{{ 'menu.create_account'|trans }}</a>
                            </li>
                            <li class="nav-user">
                                <section class="nav-user-signin">
                                    <a href="{{ path('hwi_oauth_connect') }}">{{ 'menu.sign_in'|trans }}</a>

                                    <section class="signin-box">
                                        <form action="{{ path('login') }}" method="POST" id="nav_login">
                                            <div class="input-group">
                                                <input class="form-control" type="text" id="_username" name="_username" placeholder="{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}">
                                                <span class="input-group-addon"><span class="icon-user"></span></span>
                                            </div>
                                            <div class="input-group">
                                                <input class="form-control" type="password" id="_password" name="_password" placeholder="{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}">
                                                <span class="input-group-addon"><span class="icon-lock"></span></span>
                                            </div>

                                            <div class="checkbox">
                                                <label for="_remember_me">
                                                    <input type="checkbox" id="_remember_me" name="_remember_me" value="on" checked="checked" />
                                                    {{- 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
                                                </label>
                                            </div>

                                            {%- if packagist_host and packagist_host in app.request.headers.get('Referer') %}
                                                <input type="hidden" name="_target_path" value="{{ app.request.headers.get('Referer') }}" />
                                            {%- endif %}

                                            <div class="signin-box-buttons">
                                                <a href="{{ hwi_oauth_login_url('github') }}" class="pull-right btn btn-primary btn-github"><span class="icon-github"></span>Use Github</a>
                                                <button type="submit" class="btn btn-success" id="_submit_mini" name="_submit">{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}</button>
                                            </div>
                                        </form>

                                        <div class="signin-box-register">
                                            <a href="{{ path('fos_user_registration_register') }}">{{ 'signinbox.register'|trans }}</a>
                                        </div>
                                    </section>
                                </section>
                            </li>
                        {%- endif %}
                        </ul>
                    </div>
                </div>
            </nav>
        </header>

        {{ include("PackagistWebBundle:web:search_section.html.twig", {showSearchDesc: showSearchDesc|default('show')}) }}

        {% block flashMessages %}
            {%- if app.request.hasPreviousSession and app.session.flashbag.peekAll()|length > 0 %}
            <section class="wrapper wrapper-white">
                <div class="container flash-container">
                {%- for type, flashMessages in app.flashes() %}
                    {%- for flashMessage in flashMessages %}
                        {%- if 'fos_user_' in type %}
                            <div class="alert alert-{{ type|replace({'fos_user_': ''}) }}">
                                <p>{{ flashMessage|trans({}, 'FOSUserBundle') }}</p>
                            </div>
                        {%- else %}
                            <div class="alert alert-{{ type }}">
                                <p>{{ flashMessage|trans }}</p>
                            </div>
                        {%- endif %}
                    {%- endfor %}
                {%- endfor %}
                </div>
            </section>
            {%- endif %}
        {% endblock %}

        {% block content_header %}{% endblock %}

        <section class="wrapper">
            <section class="container content" role="main">
                {% block search_results %}
                    <div id="search-container" class="hidden">
                        <div class="row">
                            <div class="search-list col-md-9"></div>

                            <div class="search-facets col-md-3">
                                <div class="search-facets-active-filters"></div>
                                <div class="search-facets-type"></div>
                                <div class="search-facets-tags"></div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-9">
                                <div id="powered-by">
                                    Search by <a href="https://www.algolia.com/"><img src="{{ asset('bundles/packagistweb/img/algolia-logo-light.svg') }}"></a>
                                </div>
                                <div id="pagination-container">
                                    <div class="pagination"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endblock %}

                {% block content %}{% endblock %}
            </section>
        </section>
    </section>

        <footer class="wrapper-footer">
            <nav class="container">
                <div class="row">
                    <ul class="social col-xs-7 col-sm-4 col-md-2 pull-right">
                        <li><a href="http://github.com/composer/packagist" title="{{ 'menu.github'|trans }}"><span class="icon-github"></span></a></li>
                        <li><a href="https://twitter.com/packagist" title="{{ 'menu.twitter'|trans }}"><span class="icon-twitter"></span></a></li>
                        <li><a href="mailto:contact@packagist.org" title="{{ 'menu.contact'|trans }}"><span class="icon-mail"></span></a></li>
                    </ul>

                    <ul class="col-xs-4 col-md-2">
                        <li><a href="{{ path('about') }}">{{ 'menu.about_packagist'|trans }}</a></li>
                        <li><a href="{{ path('feeds') }}" rel="nofollow">{{ 'menu.rss_feeds'|trans }}</a></li>
                    </ul>

                    <div class="clearfix visible-xs-block"></div>

                    <ul class="col-xs-3 col-md-2">
                        <li><a href="{{ path('stats') }}" rel="nofollow">{{ 'menu.stats'|trans }}</a></li>
                        <li><a href="{{ path('browse') }}">{{ 'menu.browse_packages'|trans }}</a></li>
                    </ul>

                    <div class="clearfix visible-xs-block"></div>

                    <ul class="col-xs-3 col-md-2">
                        <li><a href="{{ path('api_doc') }}">{{ 'menu.api_doc'|trans }}</a></li>
                        <li><a href="{{ path('mirrors') }}">{{ 'menu.mirrors'|trans }}</a></li>
                    </ul>

                </div>

                <div class="row">
                    <p class="toran col-xs-12">Packagist maintenance and hosting is provided by <a href="https://packagist.com/">Private Packagist</a></p>
                </div>
            </nav>
        </footer>

        <script>
            var algoliaConfig = {{ algolia|json_encode|raw }};
        </script>

        <script src="{{ asset('libs/jquery-2.1.4.min.js') }}"></script>
        <script src="{{ asset('libs/humane-3.2.2.min.js') }}"></script>
        <script src="{{ asset('bundles/packagistweb/js/layout.js') }}"></script>
        <script src="{{ asset('libs/bootstrap-3.3.5/js/bootstrap.min.js')}}"></script>
        <script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.7.4/dist/instantsearch.min.js"></script>
        <script src="{{ asset('bundles/packagistweb/js/search.js') }}"></script>

        {%- block analytics %}
        {%- if not app.debug and google_analytics.ga_key %}
        <script>
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

            ga('set', 'anonymizeIp', true);
            ga('create', '{{ google_analytics.ga_key }}', 'auto');
            ga('send', 'pageview');
        </script>
        {%- endif %}
        {%- endblock %}

        {% block scripts %}{% endblock %}
    </body>
</html>
